package com.dreamthen.controller;

import com.dreamthen.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author zengms
 * @Date 2023-11-12 14:08:11
 **/
@Controller
@RequestMapping("/exception")
public class ExceptionController {

    @Autowired
    private IUserService iUserService;

    @RequestMapping("/test")
    public String test() {
        return "index";
    }

    @RequestMapping("/01")
    @ResponseBody
    public String exception01(@RequestParam(value = "name") String name) {
        System.out.println("****name***" + name);
        return "index";
    }

    @RequestMapping("02")
    public String exception02() {
        return iUserService.getUser(null);
    }

    /*
    @ExceptionHandler
    public ModelAndView ex(Exception ex) {

        System.out.println("******controller-exception******");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error");
        modelAndView.addObject("ex", ex.getMessage());
        return modelAndView;

    }
*/

}
